import xlrd
from xlutils import copy
class Exel_options:
    def __init__(self,name):
        self.wb=xlrd.open_workbook(name)
        self.copy_wb=copy.copy(self.wb)
    def read_exel(self,index):
        ws=self.wb.sheet_by_index(index)
        data=[]
        row=ws.nrows
        for i in range(1,row):
            row_values=ws.row_values(i)
            row_values=row_values[0:3]
            data.append(row_values)
            data[i-1].append(i)
        return data
    def Write_Exel(self,index,row,expect,result):
        sheet=self.copy_wb.get_sheet(index)
        sheet.write(row,3,result)
        if expect == result:
            sheet.write(row,4,'成功')
        else:
            sheet.write(row,4,'失败')
        self.copy_wb.save(r'Automation.xlsx')


